package main
import (
	"fmt"
	"net"
)

func main(){
	listener, err := net.Listen("tcp", "127.0.0.1:8000")
	if err != nil{
		fmt.Println("Listen Err : ", err)
		return
	}
	fmt.Println("Link 127.0.0.1:8000")
	fmt.Printf("Receive and send data：\n")
	defer listener.Close()
	for{
		conn, err := listener.Accept()
		if err != nil{
			fmt.Println("Accept Err : ", err)
			return
		}
		buf := make([]byte, 1024)
		n, err1 := conn.Read(buf)
		if err1 != nil{
			fmt.Println("Read Err : ", err1)
			return
		}
		fmt.Println("Get Data : ", string(buf[:n]))
	}
}